import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { StoreComponent } from './store/store.component';
import { GoodsComponent } from './goods/goods.component';
import { RouterModule, Routes } from '@angular/router';
import { SharedModule } from '../../shared/shared.module';
import { LayoutComponent } from './layout/layout.component';
import { StoreGuard } from './guards/store.guard';
import { StoreNewComponent } from './store-new/store-new.component';
import { StoreActiveGuard } from './guards/store-active.guard';

const routes: Routes = [
  {
    path: '', component: LayoutComponent, canActivate: [StoreActiveGuard],
    children: [
      {path: '', redirectTo: 'goods'},
      {path: 'goods', component: GoodsComponent, canActivate: [StoreGuard]},
      {path: 'store', component: StoreComponent},
      {path: 'store/new', component: StoreNewComponent},
      {path: 'store/edit/:id', component: StoreNewComponent},
    ],
  },
];

@NgModule({
  declarations: [
    StoreComponent,
    GoodsComponent,
    LayoutComponent,
    StoreNewComponent,
  ],
  imports: [
    CommonModule,
    RouterModule.forChild(routes),
    SharedModule,
  ],
})
export class SellerModule {
}
